#include<iostream>
#include<string>
#include<map>
#include<cmath>
using namespace std;
typedef long long LL;
const int N = 1e3 + 10;
string s;
LL ans1, ans2;
map<int, int>mp;
int main()
{
	cin >> s;
	int cnt_ans = 0, cnt_ans1 = 0;
	for (int i = 0; i < s.size(); ) {
		char c = s[i];
		int idx = 0;
		if (c == 'd') {
			idx = i - 1;
			int a = 0, b = 0;
			//245
			int cnt = 0;
			bool flag = 0;
			while (idx >= 0 && s[idx] >= '0' && s[idx] <= '9') {
				a += pow(10, cnt++) * (s[idx] - '0');
				idx--;
			}
			if (!a)a = 1;
			if (s[idx] == '-') {
				flag = 1;
			}
			idx = i + 1;
			while (idx <= s.size() - 1 && s[idx] >= '0' && s[idx] <= '9') {
				b = b * 10 + (s[idx] - '0');
				idx++;
			}
			if (!mp[b]) {
				cnt_ans++;
				if (!flag) {
					mp[b] += a;
					cnt_ans1++;
				}
			}
			else {
				if (!flag) {
					mp[b] += a;
				}
			}
			if (flag) {
				ans1 += (-1) * (a * b);
				ans2 -= a;
			}
			else {
				ans1 += a;
				ans2 += a * b;
			}
			//cout << "a==" << a << endl;
			//cout << "b==" << b << endl;
			//cout << "===" << a * b << endl;
			i = idx;
		}
		else i++;
	}
	LL ans3 = 0;
	for (int i = 0; i < s.size(); ) {
		if (s[i] == '+') {
			int idx = i + 1;
			bool flag = 0;
			while (s[idx] != '+' && s[idx] != '-' && idx < s.size()) {
				if (s[idx] == 'd')flag = 1;
				idx++;
			}
			if (!flag) {
				int sum = 0;
				for (int j = i + 1; j < idx; j++) {
					sum = sum * 10 + (s[j] - '0');
				}
				//cout << "sum==" << sum << endl;
				ans3 += sum;
			}
			i = idx;
		}
		else if (s[i] == '-') {
			int idx = i + 1;
			bool flag = 0;
			while (s[idx] != '+' && s[idx] != '-' && idx < s.size()) {
				if (s[idx] == 'd')flag = 1;
				idx++;
			}
			if (!flag) {
				int sum = 0;
				for (int j = i + 1; j < idx; j++) {
					sum = sum * 10 + (s[j] - '0');
				}
				//cout << "sum==" << sum << endl;
				ans3 -= sum;
			}
			i = idx;
		}
		else i++;
	}
	cout << cnt_ans << " " << cnt_ans1 << endl;
	for (int i = 1; i <= 1000; i++) {
		if (mp[i]) {
			cout << i << " " << mp[i] << endl;
		}
	}
	cout << ans1 + ans3 << " " << ans2 + ans3 << endl;
	return 0;
	//cout << ans3 << endl;
}